﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TreeSharp;
using Styx.Combat.CombatRoutine;
using Styx;
using FelMaster.Classes;

namespace FelMaster
{
    public class Unholy : TalentBase
    {
        public override string Name
        {
            get { return "Unholy by ossirian"; }
        }

        public override float CombatMaxDistance
        {
            get
            {
                return 5f;
            }
        }

        public override Composite Buffs
        {
            get
            {
                return new PrioritySelector(
                    SC.CastSpell("Horn of Winter", a => true, "Horn of Winter")
                );
            }
        }

        public override string KeySpell
        {
            get { return "Scourge Strike"; }
        }

        public override Composite SingleRotation
        {
            get
            {
                return new PrioritySelector(
                    SC.CastBuff("Unholy Presence", a => true, "Unholy Presence"),
                    SC.CastBuff("Horn of Winter", a => true, "Horn of Winter"),
                    SC.CastBuff("Summon Gargoyle", a => SC.TargetHasDebuff("Blood Plague") && SC.TargetHasDebuff("Frost Fever") && Me.CurrentTarget.CurrentHealth > 1500000 || Me.CurrentTarget.MaxHealth == 1, "Gargoyle"),
                    SC.CastSpell("Blood Tap", a => true, "Blood Tap"),
                    SC.CastBuff("Raise Dead", a => Me.Pet == null || Me.Pet.Dead && SC.TargetHasDebuff("Blood Plague") && SC.TargetHasDebuff("Frost Fever"), "Raise Dead"),
                    SC.CastSpell("Mind Freeze", a => Me.GotTarget && Me.CurrentTarget.IsCasting, "Mind Freeze"),
                    SC.CastSpell("Dark Transformation", a => SC.IsUsableSpell("Dark Transformation"), "ZOMBIE!!!"),
                    SC.CastBuff("Unholy Frenzy", a => SC.TargetHasDebuff("Blood Plague") && SC.TargetHasDebuff("Frost Fever") && Me.CurrentTarget.CurrentHealth > 1500000 || Me.CurrentTarget.MaxHealth == 1, "Unholy Frenzy"),
                    SC.CastSpell("Outbreak", a => !SC.TargetHasDebuff("Blood Plague"), "Outbreak"),
                    SC.CastSpell("Outbreak", a => !SC.TargetHasDebuff("Frost Fever"), "Outbreak"),
                    SC.CastSpell("Plague Strike", a => !SC.TargetHasDebuff("Blood Plague"), "Plague Strike"),
                    SC.CastSpell("Icy Touch", a => !SC.TargetHasDebuff("Frost Fever"), "Icy Touch"),
                    //SC.CastSpell("Obliterate", a => SC.PlayerHasBuff("Killing Machine"), "Obliterate"),
                    SC.CastSpell("Death Coil", a => Me.ManaPercent > 80, "Death Coil"),
                    SC.CastSpell("Death Coil", a => SC.PlayerHasBuff("Sudden Doom"), "Sudden Doom"),
                    SC.CastSpell("Scourge Strike", a => true, "Scourge Strike"),
                    SC.CastSpell("Festering Strike", a => true, "Festering Strike"),
                    SC.CastSpell("Death coil", a => true, "Death coil"),
                    SC.CastSpell("Empower Rune Weapon", a => true, "Empower Rune Weapon"),
                    SC.CastSpell("Horn of Winter", a => true, "Horn of Winter")
                );
            }
        }

        public override Composite PVPRotation
        {
            get
            {
                return new PrioritySelector(
                    SC.CastBuff("Unholy Presence", a => true, "Unholy Presence"),

                    SC.CastBuff("Horn of Winter", a => true, "Horn of Winter"),

                    SC.CastBuff("Summon Gargoyle", a => SC.TargetHasDebuff("Blood Plague") && SC.TargetHasDebuff("Frost Fever") && Me.CurrentTarget.Distance < 10 && Me.GotTarget && Me.CurrentTarget.HealthPercent < 50, "Gargoyle"),

                    SC.CastSpell("Blood Tap", a => true, "Blood Tap"),

                    SC.CastBuff("Raise Dead", a => Me.Pet == null || Me.Pet.Dead && SC.TargetHasDebuff("Blood Plague") && SC.TargetHasDebuff("Frost Fever"), "Raise Dead"),

                    SC.CastSpell("Mind Freeze", a => Me.GotTarget && Me.CurrentTarget.IsCasting, "Mind Freeze"),

                    SC.CastSpell("Strangulate", a => Me.CurrentTarget.HealthPercent < 40 && Me.GotTarget && Me.CurrentTarget.IsCasting, "Strangulate"),

                    //SC.CastSpell("Death Grip", a => Me.CurrentTarget.Distance < 5 && Me.GotTarget && Me.CurrentTarget.IsCasting, "Death Grip"),

                    SC.CastSpell("Anti-Magic Shell", a => Me.GotTarget && Me.CurrentTarget.IsCasting, "Anti-Magic Shell"),

                    SC.CastSpell("Anti-Magic Shell", a => Me.HealthPercent < 95, "Anti-Magic Shell"),

                    //SC.CastSpell("Icebound Fortitude", a => Me.HealthPercent < 50, "Icebound Fortitude"),

                    SC.CastSpell("Death Pact", a => Me.HealthPercent < 40 && SC.IsUsableSpell("Raise Dead"), "Death Pact"),

                    SC.CastSpell("Dark Transformation", a => Me.CurrentTarget.Distance < 10 && Me.GotTarget && Me.CurrentTarget.HealthPercent < 50 && SC.IsUsableSpell("Dark Transformation"), "ZOMBIE!!!"),

                    SC.CastBuff("Unholy Frenzy", a => SC.TargetHasDebuff("Blood Plague") && SC.TargetHasDebuff("Frost Fever") && Me.CurrentTarget.Distance < 10 && Me.GotTarget && Me.CurrentTarget.HealthPercent < 50, "Unholy Frenzy"),

                    SC.CastSpell("Outbreak", a => !SC.TargetHasDebuff("Blood Plague"), "Outbreak"),

                    SC.CastSpell("Outbreak", a => !SC.TargetHasDebuff("Frost Fever"), "Outbreak"),

                    //SC.CastSpell("Death Grip", a => Me.CurrentTarget.Distance > 15, "Death Grip"),

                    SC.CastSpell("Plague Strike", a => !SC.TargetHasDebuff("Blood Plague"), "Plague Strike"),

                    SC.CastSpell("Chains of Ice", a => !SC.TargetHasDebuff("Frost Fever"), "Chains of Ice"),

                    SC.CastSpell("Chains of Ice", a => Me.CurrentTarget.Distance > 10 && !SC.TargetHasDebuff("Chains of Ice"), "Chains of Ice"),

                    SC.CastSpell("Death Coil", a => Me.ManaPercent > 80, "Death Coil"),

                    SC.CastSpell("Death Coil", a => SC.PlayerHasBuff("Sudden Doom"), "Sudden Doom"),

                    SC.CastSpell("Death Strike", a => Me.HealthPercent > 50, "Death Strike"),

                    SC.CastSpell("Scourge Strike", a => Me.GotTarget && Me.CurrentTarget.HealthPercent < 50, "Scourge Strike"),

                    SC.CastSpell("Necrotic Strike", a => true, "Necrotic Strike"),

                    SC.CastSpell("Festering Strike", a => true, "Festering Strike"),

                    SC.CastSpell("Death coil", a => true, "Death coil"),

                    SC.CastSpell("Empower Rune Weapon", a => Me.CurrentTarget.Distance < 10 && Me.GotTarget && Me.CurrentTarget.HealthPercent < 50, "Empower Rune Weapon"),

                    SC.CastSpell("Horn of Winter", a => true, "Horn of Winter")
                );
            }
        }

        public override Composite PVERotation
        {
            get { return SingleRotation; }
        }
    }
}
